<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="./jquery-1.7.2.js"></script>
</head>

<body>
    用户名<input type="text" id="usern">
    密码<input type="text" id="passw">
    <button>点击注册</button>
    <script>
        $(function () {
            const test = document.querySelector('button');
            test.addEventListener('click', () => {
                // console.log($('#usern').val())
                var usern_data = $('#usern').val();
                var passw_data = $('#passw').val();
                $.ajax({
                    type:'post',
                    url:'http://localhost:8080/api/reguser',
                    data:{
                        username:`${usern_data}`,
                        password:`${passw_data}`
                    },
                    success:(req,res)=>{
                        console.log(req);
                        console.log(res);
                    }
                });
            });
        })
    </script>
</body>

</html>